package com.example.user.controller;

import com.example.user.service.ApRealNameService;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.common.enums.AppHttpCodeEnum;
import com.usian.model.user.dtos.AuthDto;
import com.usian.model.user.pojos.ApUserRealname;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/v1/real_name")
@Api(tags = "实名认证的接口")
public class ApRealNameController {


    @Autowired
    private ApRealNameService apRealNameService;

    /**
     * 根据状态查询实名认证信息列表
     *
     * @param authDto
     * @return
     */
    @PostMapping("/get_real_name_param")
    public ResponseResult getRealNameByParam(@RequestBody AuthDto authDto) {

        List<ApUserRealname> realnameList = apRealNameService.getRealNameByParam(authDto);
        if (CollectionUtils.isEmpty(realnameList)) {
            return ResponseResult.errorResult(AppHttpCodeEnum.DATA_NOT_EXIST);
        }
        return ResponseResult.okResult(realnameList);

    }

    /**
     * 实名认证审核
     * @param authDto
     * @return
     */
    @PostMapping("check")
    public ResponseResult check(@RequestBody AuthDto authDto) {
        return apRealNameService.check(authDto);
    }


}
